Skip to content

compat: make PHP 8 HTML escaping behavior explicit - #333

Open
somethingwithproof wants to merge 4 commits into
Cacti:developfrom
somethingwithproof:fix/php8-deprecations
Open

compat: make PHP 8 HTML escaping behavior explicit#333
somethingwithproof wants to merge 4 commits into
Cacti:developfrom
somethingwithproof:fix/php8-deprecations

Conversation

@somethingwithproof

Copy link
Copy Markdown
Member

Summary

  • Pass explicit ENT_QUOTES | ENT_SUBSTITUTE flags and UTF-8 to the remaining htmlspecialchars() call.
  • Preserve PHP 8.1+ behavior while removing the cross-version compatibility finding.
  • Record the compatibility cleanup in the develop changelog.

Audit result

A whole-plugin PHPCompatibility scan for PHP 8.0+ found five findings on develop. This PR resolves the htmlspecialchars() finding. The other four are omitted fputcsv() escape arguments and are already resolved in #326.

Validation

  • setup.php passes PHP lint.
  • setup.php is clean under PHPCompatibility with testVersion 8.0-.
  • The full pre-push review gate passed.

CI infrastructure repair #329 should merge first so this PR inherits the corrected PHP matrix after rebase.

Cacti core now requires PHP >= 8.2, so the 8.1 integration job fails the
composer platform check; Ubuntu Noble also lacks libapache2-mod-php for
non-native versions without the ondrej PPA.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The updated HTML output still leaves a newly-touched localized attribute unescaped, and the CI workflow edits introduce reliability/scope concerns (add-apt-repository dependency + PHP 8.1 matrix drop) that should be resolved before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR aims to make HTML escaping behavior consistent across PHP 8 versions by making the remaining htmlspecialchars() call explicit, and records the compatibility cleanup in the changelog. It also includes CI workflow adjustments affecting the PHP matrix and package installation steps.

Changes:

  • Make htmlspecialchars() behavior explicit by passing ENT_QUOTES | ENT_SUBSTITUTE and UTF-8.
  • Add a develop changelog entry documenting the compatibility cleanup.
  • Adjust GitHub Actions integration-test workflow (PHP matrix and apt repository setup).
File summaries
File Description
setup.php Makes HTML escaping explicit for a generated syslog link in graph buttons.
CHANGELOG.md Adds a develop entry noting the escaping/compatibility adjustment.
.github/workflows/plugin-ci-workflow.yml Updates integration-test PHP matrix and modifies apt repository setup prior to installing Apache PHP packages.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +142 to +145
- name: Run apt-get update
run: sudo apt-get update
run: |
sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update
Comment thread setup.php Outdated
Comment on lines +1595 to +1597
$url = $config['url_path'] . 'plugins/syslog/syslog.php?tab=syslog&reset=1&host=' . $host_id . '&date1=' . $date1 . '&date2=' . $date2;

print "<a class='iconLink' href='" . htmlspecialchars($url, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') . "' title='" . __('Display Syslog in Range', 'syslog') . "'><i class='deviceRecovering fas fa-exclamation-triangle'></i></a><br>";
Comment on lines 96 to 100
strategy:
fail-fast: false
matrix:
php: ['8.1', '8.2', '8.3']
php: ['8.2', '8.3']
os: [ubuntu-latest]
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Install software-properties-common before add-apt-repository so the ondrej
PPA step does not depend on an undeclared runner image package.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants